package application;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;

import role.User;

public class QixiDao {
	public QixiDao(Session session) {
		super();
		this.session = session;
	}

	private Session session;
	
	public List  list(String gender){
		Query user = session.createQuery("from user where u.gender=gender ",User.class);
	}
	public void insert(User user) {
		Transaction ts = session.beginTransaction();
		try {
			session.save(user);
			ts.commit();
		} catch (Exception e) {
			ts.rollback();
		}
	}

	public void delete(User user) {
		Transaction ts = session.beginTransaction();
		try {
			session.delete(user);
			ts.commit();
		} catch (Exception e) {
			ts.rollback();
		}
	}

	public void update(User user) {
		Transaction ts = session.beginTransaction();
		try {
			session.update(user);
			ts.commit();
		} catch (Exception e) {
			ts.rollback();
		}
	}
}
